<!DOCTYPE html>
<html lang="en">
<head>
    <title>客户列表（手机App）</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>

    <style>
        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 12px;
        }

        body {
            margin: 1px;
            background: #f8f8f8;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }
        th{
            font-weight: bold;
        }
        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: 12px;
        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
            height: 24px;
            position: relative;
            color:#333;
            padding: 0 4px;
        }

        .table th {
            background: yellow;
        }

        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
        }

        .tdColor {
            background-color: #f8f8f8;
            font-weight: bold;
        }

        .lineOne span {
            max-height: 24px;
            line-height: 24px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .lineTwo span {
            max-height: 48px;
            line-height: 14px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
            text-align: left;

        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .clear {
            clear: both
        }

        .jiaobiao {
            position: relative;
        }

        .jiaobiao i {
            display: block;
            width: 0;
            height: 0;
            border-width: 0px 0 12px 12px;
            border-style: solid;
            border-color: transparent transparent transparent #f8f8f8;
            position: absolute;
            top: 0px;
            left: 0px;
        }

        .lineImg img{
            height: 45px;
            width: 45px;
            float: left;
            margin-right: 5px;
        }
        .newCustomer{
            background: url(/dist/img/new.png) no-repeat;
            background-size: cover;
            width: 20px;
            height: 20px;
            right: 0;
            top: 2px;
            position: absolute;
        }
        .btn-blue {
            border: none;
            background: #2a8ced;
            color: #fff;

            height: 30px;
            width: 14%;

            border-radius:3px;
        }
        .btn-blue.focus, .btn-blue:focus, .btn-blue:hover {
            color: #fff;
            text-decoration: none;
        }
        .formbox {
            padding: 10px;
        }
        .jiaobiao, .jiaobiaoNew {
            position: relative;
        }

        .jiaobiao i {
            display: block;
            width: 0;
            height: 0;
            border-width: 0px 0 12px 12px;
            border-style: solid;
            border-color: transparent transparent transparent #2a8cec;
            position: absolute;
            top: 0px;
            left: 0px;
        }

        .jiaobiaoNew i {
            display: block;
            width: 12px;
            height: 12px;
            background: url("/dist/img/newLog2.png");
            background-size: 100% 100%;
            position: absolute;
            top: 0px;
            left: 0px;
        }
    </style>
</head>
<body>
<section class="content" id="app" v-cloak style="background: #fff;">
    <div class="div-td-content-more"><i></i></div>

    <div style="margin: 5px 0;">
        <input type="text" placeholder="搜索关键字" id="searchKey" size="12" style="width:70%;height: 30px;vertical-align: top;" v-model="key" class="pd_1">
        <button type="button" class="btn btn-blue" @click="getSearchList">查询</button>
        <button type="button" class="btn btn-blue" @click="getAll">全部</button>
    </div>

        <div class="boxBoy" style="overflow: auto;width: 100%;" id="scrollDiv" >

            <table class="table table-bordered text-center table-width" v-for="(item,i) in customer">
                <tbody>
                <tr>
                    <td class="tdColor jiaobiao" style="width: 25%;"><i></i>客户姓名</td>
                    <td @click="openCustomerList(item.id,item.name)"
                        style="color: #169BD5;cursor: pointer;width: 25%;">{{item.name?item.name:"-"}}<span v-if="customer.newCustomer=='1'" class="newCustomer"></span></td>
                    <td class="tdColor" style="width: 25%;">客户电话</td>
                    <td style="width: 25%;"><span>{{item.tel?item.tel:"-"}}</span></td>
                </tr>
                <!--<tr>
                    <td class="tdColor">客户微信</td>
                    <td ><span>{{item.wechat}}</span></td>
                    <td class="tdColor">已有设备</td>
                    <td ><span>{{item.existingDevice}}</span></td>
                </tr>-->
                <tr>
                    <td class="tdColor">客户类型</td>
                    <td ><span>{{customer.customerType?customer.customerType:"-"}}</span></td>
                    <td class="tdColor">客户信用</td>
                    <td ><span>{{customer.customerCredit?customer.customerCredit:"-"}}</span></td>
                </tr>
                <tr>
                    <td class="tdColor">客户所在地</td>
                    <td ><span>{{item.provinceName?item.provinceName:"-"}}</span></td>
                    <td class="tdColor">购买日期</td>
                    <td ><span>{{item.buyDate?item.buyDate:"-"}}</span></td>
                </tr>
                <tr>
                    <td class="tdColor">意向机型</td>
                    <td ><span>{{item.intentionModel?item.intentionModel:"-"}}</span></td>
                    <td class="tdColor">购买方式</td>
                    <td ><span>{{item.buyType?item.buyType:"-"}}</span></td>
                </tr>
                <tr>
                    <td class="tdColor">基本情况</td>
                    <td colspan="3" class="lineTwo"><span>{{item.otherCondition}}</span></td>
                </tr>
                </tbody>
            </table>
        </div>
    <div class="oa-pager" style="margin-top: 5px;margin-left: 5px;text-align: center;" v-if="">
        共
        <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
        <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
        <span class="oa-pager-button" id="first">首页</span>
        <span class="oa-pager-button" id="prev" style="border-bottom: 1px solid red;">上一页</span>
        <span class="oa-pager-button" id="next" style="border-bottom: 1px solid red;">下一页</span>
        <span class="oa-pager-button" id="last">尾页</span>
    </div>
        <div class="clear"></div>

</section>
<!--rem.js-->
<script src="/dist/js/pages/rem/rem.js"></script>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="/dist/plugins/scroll/myScroll.js"></script>
<!--框架已定义 JS-->
<!--oa自定义  JS-->
<script src="/dist/js/oaApp.js"></script>

<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {

        },
        error: function (e) {
            alert('error' + e.responseText);
        }
    });
    $.extend($.wyui, {
        page: {
            urlParams: null,
            queryParams: {
                requestPage: 1,
                pageSize: 30
            },
            dataUrl: '',
            getByPage_callback: null,
            createQueryParams: function () {
            },
            getByPage: function (type) {
                if(type=="scroll"){
                    $.wyui.page.queryParams.requestPage++;
                }
                $.ajax({
                    url: $.wyui.page.dataUrl,
                    data: JSON.stringify($.wyui.page.queryParams),
                    beforeSend: function () {

                    },
                    complete: function () {
                    },
                    success: function (r) {
                        $("#allCount").html(r.data.sendData.pager.recordCount);
                        $("#nowPage").html($.wyui.page.queryParams.requestPage);
                        if (r.data.sendData.pager.pageCount == 0) {
                            r.data.sendData.pager.pageCount = 1;
                        }
                        $("#allPage").html(r.data.sendData.pager.pageCount);
                        if(type=="scroll"){
                            $.wyui.page.getByPage_scroll_callback(r.data.sendData.records);
                        }else{
                            $.wyui.page.getByPage_callback(r.data.sendData.records);
                            if($.wyui.page.getByPage_callback_new){
                                $.wyui.page.getByPage_callback_new(r.data.sendData);
                            }
                        }

                    }
                });
            }
        },
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {

                },
                complete: function () {
                    setTimeout(function () {
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        alert(r.e.desc);
                    }
                },
                error: function (e) {
                    alert(url + e.responseText);
                }
            });
        },
    });
</script>
<script type="text/javascript">
    function refresh() {
        $.wyui.page.getByPage();
    }
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width":"100%",
                        "left": 0,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });


    var app = new Vue({
        el: '#app',
        data: {
            userId: getUrlParamObj().userId,
            key:'',
            dateTime:'',
            customer: {
                list:[]
            }
        },
        methods: {
            getList: function () {
                var that=this;
                $.wyui.page.dataUrl = server.ip + urlConfig.report.customerReport.getAllCustomerList
                $.wyui.page.queryParams.requestPage=1;
                $.extend($.wyui.page.queryParams, {userId: app.userId, key: app.key});
                $.wyui.page.getByPage();
            },
            getSearchList: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.customerReport.getAllCustomerList, {
                    "userId": that.userId,
                    key:that.key,
                    dateTime:'',
                    pageSize:30,
                    requestPage:1
                }, function (data) {
                    console.log(data);
                    that.customer=data.records;
                });
                },
            getAll:function () {
                var that=this;
                that.key = '';
                $.wyui.postMethod(urlConfig.report.customerReport.getAllCustomerList, {
                    "userId": that.userId,
                    key:'',
                    dateTime:'',
                    pageSize:30,
                    requestPage:1
                }, function (data) {
                    console.log(data);
                    that.customer=data.records;
                });
            },

            //打开大区经理意向客户列表
            openCustomerList: function (customerId, name,userId) {
                var that = this;
                var obj = {
                    type: 'lookPersonnel',
                    url: '/reportForm/customer/intentionalCustomerBigRegionApp.html?customerId='  + customerId+ '&userId=' + userId ,
                    name: name,
                    dateTime: ''
                }
                console.log(JSON.stringify(obj));
                prompt(JSON.stringify(obj));
            }
        },
        mounted: function () {
            $(".oa-pager-button").click(function () {
                var allPage = parseInt($("#allPage").html());
                switch (this.id) {
                    case "first":
                        $.wyui.page.queryParams.requestPage = 1;
                        break;
                    case "next":
                        $.wyui.page.queryParams.requestPage++;
                        break;
                    case "prev":
                        $.wyui.page.queryParams.requestPage--;
                        break;
                    case "last":
                        $.wyui.page.queryParams.requestPage = allPage;
                        break;
                    default:
                        break;
                }
                if ($.wyui.page.queryParams.requestPage == 0) {
                    $.wyui.page.queryParams.requestPage = 1;
                } else if ($.wyui.page.queryParams.requestPage > allPage) {
                    $.wyui.page.queryParams.requestPage = allPage;
                }
                $.wyui.page.getByPage();
            });
        }
    });
        $.wyui.page.dataUrl = server.ip + urlConfig.report.customerReport.getAllCustomerList;
    //    if($.wyui.page.urlParams.isAll=="false"){
    //        $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getForPersonalIntentCustomerList;
    //    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.extend($.wyui.page.queryParams, {userId: app.userId, key: app.key});
    $.wyui.page.getByPage()
    $.wyui.page.getByPage_callback = function (records) {
        console.log(records)
        app.customer = records;
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.customer.list.push(list[i]);
            }
            isLoad = true;
        }
    }
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
</body>
</html>